const HOST_URI = 'https://2020.comelygift.com/api/'

const HOME = 'index/index'
// 获取需求
const SEARCH_LIST = 'search/list'
// 发布需求
const REQUIREMENT_ADD = 'requirement/add'

const REQUIREMENT_DETAIL = 'requirement/detail'

function queryString (obj?: Object) {
  if (!obj) {
    return ''
  }
  return '?' + Object.keys(obj).map(function (k) {
    return encodeURIComponent(k) + '=' + encodeURIComponent(obj[k])
  }).join('&')
}

function getHome () {
  return HOST_URI + HOME
}

function getSearchList (o?) {
  return HOST_URI + SEARCH_LIST + queryString(o)
}

function getRequirementAdd() {
  return HOST_URI + REQUIREMENT_ADD；
}

function getRequirementDetail(o?) {
  return HOST_URI + REQUIREMENT_DETAIL + queryString(o)；
}

export default {
  getHome,
  getSearchList,
  getRequirementAdd,
  getRequirementDetail
}
